package fr.cephb.joperon.core.entities;
import com.sleepycat.db.DatabaseEntry;
import com.sleepycat.db.DatabaseException;

import fr.cephb.joperon.core.bio.AcidNucleicUtil;
import fr.cephb.joperon.core.entities.base.BaseSnpSeq;


/**
 * SnpSeq
 * Description: SNP sequence (ref.)
 * used to generate FASTA sequence from a FID
 * @see fr.cephb.joperon.core.entities.base.BaseSnpSeq
 * @see fr.cephb.joperon.core.entities.base.PojoSnpSeq
 * @see fr.cephb.joperon.core.db.base.BaseSnpSeqDB
 * @see fr.cephb.joperon.core.db.SnpSeqDB
 */
public class SnpSeq
	extends BaseSnpSeq
	{
	/**
     *
     * Constructor
     *
     */
	public SnpSeq()
		{
		super();
		}


        /**
         *
         * Copy Constructor
         *
         */
		public SnpSeq(BaseSnpSeq cp)
			{
			super(cp);
			}
		
		/**
		 * constructor from a database entry
		 *
		 */
		public SnpSeq(DatabaseEntry entry) throws DatabaseException
			{
			super(entry);
			}
		
		
        /**
         *
         * clone
         *
         */
		public Object clone()
			{
			return new SnpSeq(this);
			}
		
		/** return a title for a Fasta sequence */
		public String getTitle()
			{
			StringBuilder b= new StringBuilder();
			//b.append("orgqnism").append(getFid().getOrganism().).append("|");
			b.append("chr:").append(getChromosome().toString()).append("|");
			b.append("position:").append(getPosition()).append("|");
			b.append("fid:").append(getFid().asString()).append("|");
			b.append("ref:").append(getRef()).append("|");
			b.append("alt:").append(getAlt());
			return b.toString();
			}
		
		/** return this as a DNA sequence  with brackets around the mutation */
		public String asFastaSequence()
			{
			return 
				this.getOne()+"["+
				AcidNucleicUtil.dnastr_alleles_to_iupac(this.getRef()+"/"+this.getAlt())+
				"]"+this.getTwo()
				;
			}
		
		}

